EMT Practice Test

1. Question Content...


Question List

Question1: You want to use different AMI images for different regions and for the purpose you have defined following code block.
1.variable "images"
2.{
3. type = "map"
4.
5. default = {
6. us-east-1 = "image-1234"
7. us-west-2 = "image-4567"
8. us-west-1 = "image-4589"
9. }
10.}
What of the following approaches needs to be followed in order to select image-4589?

Question2: You have created a terraform script that uses a lot of new constructs that have been introduced in terraform v0.12. However, many developers who are cloning the script from your git repo, are using v0.11, and getting errors. What can be done from your end to solve this problem?

Question3: You have used Terraform to create an ephemeral development environment in the cloud and are now ready to destroy all the infrastructure described by your Terraform configuration. To be safe, you would like to first see all the infrastructure that will be deleted by Terraform.
Which command should you use to show all of the resources that will be deleted? (Choose two.)

Question4: What allows you to conveniently switch between multiple instances of a single configuration within its single backend?

Question5: Which option can not be used to keep secrets out of Terraform configuration files?

Question6: What advantage does an operations team that uses infrastructure as code have?

Question7: What is the standard workflow that a developer follows while working with terraform open source version?

Question8: You have created a custom variable definition file my_vars.tfvars. How will you use it for provisioning infrastructure?

Question9: What is terraform refresh intended to detect?

Question10: You wanted to destroy some of the dependent resources from real infrastructure. You choose to delete those resources from your configuration file and run terraform plan and then apply. Which of the following way your resources would be destroyed?

Question11: Choose the answer that correctly completes the sentence: _______backends support state locking.

Question12: What is the purpose of using the local-exec provisioner? (Select Two)

Question13: If writing Terraform code that adheres to the Terraform style conventions, how would you properly indent each nesting level compared to the one above it?

Question14: You cannot publish your own modules on the Terraform Registry.

Question15: You have provisioned some aws resources in your test environment through Terraform for a POC work. After the POC, now you want to destroy the resources but before destroying them you want to check what resources will be getting destroyed through terraform. what are the options of doing that? (Select TWO)

Question16: If you delete a remote backend from the configuration, will you need to rebuild your state files locally?

Question17: You're building a CI/CD (continuous integration/ continuous delivery) pipeline and need to inject sensitive variables into your Terraform run.
How can you do this safely?

Question18: Environment variables can be used to set variables. The environment variables must be in the format "____"_<variablename>. Select the correct prefix string from the following list.

Question19: Which task does teraform ini- not perform?

Question20: Named workspaces are not a suitable isolation mechanism for strong separation between staging and production?

Question21: Terraform variable names are saved in the state file.

Question22: Matt wants to import a manually created EC2 instance into terraform so that he can manage the EC2 instance through terraform going forward. He has written the configuration file of the EC2 instance before importing it to Terraform. Following is the code:
resource "aws_instance" "matt_ec2" { ami = "ami-bg2640de" instance_type = "t2.micro" vpc_security_group_ids = ["sg-6ae7d613", "sg-53370035"] key_name = "mysecret" subnet_id = "subnet-9e3cfbc5" } The instance id of that EC2 instance is i-0260835eb7e9bd40 How he can import data of EC2 to state file?

Question23: What does terrafom plan do ?

Question24: If a DevOps team adopts AWS Cloud Formation as their standardized method for provisioning public cloud resources, which of the following scenarios poses a challenge for this team?

Question25: Anyone can publish and share modules on the Terraform Public Module Registry, and meeting the requirements for publishing a module is extremely easy. Select from the following list all valid requirements. (select three)

Question26: Which of the following is considered a Terraform plugin?

Question27: Which of the following value will be accepted for my_var?
1. variable "my_var"
2. {
3. type = string
4. }

Question28: Which of the following connection types are supported by the remote-exec provisioner? (select two)

Question29: All standard backend types support state storage, locking, and remote operations like plan. apply and destroy.

Question30: Given the below resource configuration -
resource "aws_instance" "web" { # ... count = 4 }
What does the terraform resource address aws_instance.web refer to?

Question31: What does this code do?

Question32: What is the name assigned by Terraform to reference this resource?

Question33: Jack is a newbieto Terraform and wants to enable detailed logging to find all the details. Which environment variable does he need to set?

Question34: How does Terraform handle working with so many providers?

Question35: You decide to move a Terraform state file to Amazon S3 from another location. You write the code below into a file called\

You immediately run terraform apply but don't see any changes. Your state file didn't move. Which command will migrate your current state file to the new S3 remote backend?

Question36: A single terraform resource file that defines an aws_instance resource can simple be renamed to azurerm_virtual_machine in order to switch cloud providers

Question37: What is the workflow for deploying new infrastructure with Terraform?

Question38: Which one of the following command will rewrite Terraform configuration files to a canonical format and style.

Question39: You have declared an input variable called environment in your parent module. What must you do to pass the value to a child module in the configuration?

Question40: Which of the following is not a valid Terraform string function?

Question41: Workspaces in Terraform provides similar functionality in the open-source, Terraform Cloud, and Enterprise versions of Terraform.

Question42: Which one is the right way to import a local module names consul?

Question43: One remote backend configuration always maps to a single remote workspace.

Question44: Which one of the following will run echo 0 and echo 1 on a newly created host?

Question45: Module version is required to reference a module on the Terraform Module Registry.

Question46: In contrast to Terraform Open Source, when working with Terraform Enterprise and Cloud Workspaces, conceptually you could think about them as completely separate working directories.

Question47: When using remote state, state is only ever held in memory when used by Terraform.

Question48: The terraform init command is always safe to run multiple times, to bring the working directory up to date with changes in the configuration. Though subsequent runs may give errors, this command will never delete your existing configuration or state.

Question49: After creating a new workspace "PROD" you need to run the command terraform select PROD to switch to it.

Question50: You have provisioned some virtual machines (VMs) on Google Cloud Platform (GCP) using the gcloud command line tool. However, you are standardizing with Terraform and want to manage these VMs using Terraform instead.
What are the two things you must do to achieve this? (Choose two.)

Question51: When TF_LOG_PATH is set, TF_LOG must be set in order for any logging to be enabled.

Question52: Your DevOps team is currently using the local backend for your Terraform configuration. You would like to move to a remote backend to begin storing the state file in a central location.
Which of the following backends would not work?

Question53: The Security Operations team of ABC Enterprise wants to mandate that all the Terraform configuration that creates an S3 bucket must have encryption feature enabled. What is the best way to achieve it?

Question54: You have modified your Terraform configuration to fix a typo in the Terraform ID of a resource from aws_security_group.http to aws_security_group.http

Which of the following commands would you run to update the ID in state without destroying the resource?

Question55: Resources in terraform can have same identifiers(Resource type + Block name).

Question56: True or False? When using the Terraform provider for Vault, the tight integration between these HashiCorp tools provides the ability to mask secrets in the terraform plan and state files.

Question57: Refer to the below code where developer is outputting the value of the database password but has used sensitive parameter to hide the output value in the CLI.
output "db_password" { value = aws_db_instance.db.password description = "The password for logging in to the database." sensitive = true} Since sensitive is set to true, the value associated with db password will not be present in state file as plain-text?

Question58: The terraform.tfstate file always matches your currently built infrastructure.

Question59: You have deployed a new webapp with a public IP address on a clod provider. However, you did not create any outputs for your code.
What is the best method to quickly find the IP address of the resource you deployed?

Question60: Which of the following is not a valid Terraform collection type?

Question61: Given the Terraform configuration below, in which order will the resources be created?

Question62: You need to constrain the GitHub provider to version 2.1 or greater.
Which of the following should you put into the Terraform 0.12 configuration's provider block?

Question63: You've used Terraform to deploy a virtual machine and a database. You want to replace this virtual machine instance with an identical one without affecting the database. What is the best way to achieve this using Terraform?

Question64: In order to reduce the time it takes to provision resources, Terraform uses parallelism. By default, how many resources will Terraform provision concurrently?

Question65: The current implementation of Terraform import can only import resources into the state. It does not generate configuration.

Question66: Consider the following Terraform 0.12 configuration snippet:
1. variable "vpc_cidrs" {
2. type = map
3. default = {
4. us-east-1 = "10.0.0.0/16"
5. us-east-2 = "10.1.0.0/16"
6. us-west-1 = "10.2.0.0/16"
7. us-west-2 = "10.3.0.0/16"
8. }
9. }
10.
11. resource "aws_vpc" "shared" {
12. cidr_block = _____________
13. }
How would you define the cidr_block for us-east-1 in the aws_vpc resource using a variable?

Question67: Given the Terraform configuration below, in which order will the resources be created?
1. resource "aws_instance" "web_server"
2. {
3. ami = "ami-b374d5a5"
4. instance_type = "t2.micro"
5. }
6. resource "aws_eip" "web_server_ip"
7. {
8. vpc = true instance = aws_instance.web_server.id
9. }

Question68: Why should secrets not be hard coded into Terraform code? Choose two correct answers

Question69: In order to make a Terraform configuration file dynamic and/or reusable, static values should be converted to use what?

Question70: During a terraform plan, a resource is successfully created but eventually fails during provisioning. What happens to the resource?

Question71: Which of the below options is a valid interpolation syntax for retrieving a data source?

Question72: When configuring a remote backend in Terraform, it might be a good idea to purposely omit some of the required arguments to ensure secrets and other important data aren't inadvertently shared with others. What are the ways the remaining configuration can be added to Terraform so it can initialize and communicate with the backend? (select three)

Question73: Ric wants to enable detail logging and he wants highest verbosity of logs. Which of the following environment variable settings is correct option for him to select.

Question74: Which of the below options is the equivalent Terraform 0.12 version of the snippet which is written in Terraform 0.11?
"${var.instance_id}"

Question75: You have never used Terraform before and would like to test it out using a shared team account for a cloud provider. The shared team account already contains 15 virtual machines (VM). You develop a Terraform configuration containing one VM, perform terraform apply, and see that your VM was created successfully.
What should you do to delete the newly-created VM with Terraform?

Question76: How would you reference the "name" value of the second instance of this fictitious resource?

Question77: What information does the public Terraform Module Registry automatically expose about published modules?

Question78: Which of the following is not true of Terraform providers?

Question79: You are reviewing Terraform configurations for a big project in your company. You noticed that there are several identical sets of resources that appear in multiple configurations. What feature of Terraform would you recommend to use to reduce the amount of cloned configuration between the different configurations?

Question80: Your manager has instructed you to start using terraform for the entire infra provisioning of the application stack. There are 4 environments - DEV , QA , UAT , and PROD. The application team has asked for complete segregation between these environments including the backend , state , and also configurations ,since there will be unique resources in different environments . What is the possible way to structure the terraform code to facilitate that.

Question81: Which of the following type of variable allows multiple values of several distinct types to be grouped together as a single value?

Question82: How is the Terraform remote backend different than other state backends such as S3, Consul, etc.?

Question83: Which backend does the Terraform CLI use by default?

Question84: You have been given requirements to create a security group for a new application. Since your organization standardizes on Terraform, you want to add this new security group with the fewest number of lines of code. What feature could you use to iterate over a list of required tcp ports to add to the new security group?

Question85: Which of the following challenges would Terraform be a candidate for solving? (Select THREE)

Question86: Which of the following Terraform commands will automatically refresh the state unless supplied with additional flags or arguments? Choose TWO correct answers.

Question87: By default, provisioners that fail will also cause the Terraform apply itself to error. How can you change this default behavior within a provisioner?

Question88: Select all features which are exclusive to Terraform Enterprise. (Select Three)

Question89: colleagues is new toTerraform and wants to add a new workspace named new-hire.
What command he should execute from the following?

Question90: A user has created three workspaces using the command line - prod, dev, and test. The user wants to create a fourth workspace named stage. Which command will the user execute to accomplish this?

Question91: Terraform has detailed logs which can be enabled by setting the _________ environmental variable.

Question92: While using generic git repository as a module source, which of the below options allows terraform to select a specific version or tag instead of selecting the HEAD.

Question93: You have to initialize a Terraform backend before it can be configured.

Question94: Where does the Terraform local backend store its state?

Question95: Your company has a lot of workloads in AWS , and Azure that were respectively created using CloudFormation , and AzureRM Templates. However , now your CIO has decided to use Terraform for all new projects , and has asked you to check how to integrate the existing environment with terraform code. What should be your next plan of action?

Question96: If a module uses a local variable, you can expose that value with a terraform output.

Question97: terraform refresh will update the state file?

Question98: A user runs terraform init on their RHEL based server and per the output, two provider plugins are downloaded: $ terraform init Initializing the backend...
Initializing provider plugins...
- Checking for available provider plugins...
- Downloading plugin for provider "aws" (hashicorp/aws) 2.44.0...
- Downloading plugin for provider "random" (hashicorp/random) 2.2.1...
:
Terraform has been successfully initialized! Where are these plugins downloaded to?

Question99: The terraform state command can be used to ____

Question100: John wants to use two different regions to deploy two different EC2 instances. He has specified two provider blocks in his providers.tf file.
provider "aws" { region = "us-east-1" }
provider "aws" { region = "us-west-2" }
When he run terraform plan he encountered an error. How to fix this?

Question101: Which two steps are required to provision new infrastructure in the Terraform workflow? (Choose two.)

Question102: A Terraform output that sets the ''sensitive'' argument to true will not store that value in the state file.

Question103: John is writing a module and within the module, there are multiple places where he has to use the same conditional expression but he wants to avoid repeating the same values or expressions multiple times in a configuration,. What is a better approach to dealing with this?

Question104: What does the command terraform fmt do?

Question105: Why is it a good idea to declare the required version of a provider in a Terraform configuration file?
1. terraform
2. {
3. required_providers
4. {
5. aws = "~> 1.0"
6. }
7. }

Question106: What is the command you can use to set an environment variable named "var1"of type String?

Question107: Your company has been using Terraform Cloud for a some time now . But every team is creating their own modules , and there is no standardization of the modules , with each team creating the resources in their own unique way . You want to enforce a standardization of the modules across the enterprise . What should be your approach.

Question108: Your team uses terraform OSS . You have created a number of resuable modules for important , independent network components that you want to share with your team to enhance consistency . What is the correct option/way to do that?

Question109: Which of the following statements about local modules is incorrect:

Question110: You write a new Terraform configuration and immediately run terraform apply in the CLI using the local backend.
Why will the apply fail?

Question111: If a Terraform creation-time provisioner fails, what will occur by default?

Question112: What features stops multiple admins from changing the Terraform state at the same time?

Question113: 1. resource "aws_s3_bucket" "example" {
2. bucket = "my-test-s3-terraform-bucket"
3. ...} resource "aws_iam_role" "test_role" {
4. name = "test_role"
5. ...}
Due to the way that the application code is written, the s3 bucket must be created before the test role is created, otherwise there will be a problem. How can you ensure that?

Question114: Your team has started using terraform OSS in a big way , and now wants to deploy multi region deployments (DR) in aws using the same terraform files . You want to deploy the same infra (VPC,EC2 ...) in both us-east-1 ,and us-west-2 using the same script , and then peer the VPCs across both the regions to enable DR traffic. But , when you run your script , all resources are getting created in only the default provider region. What should you do? Your provider setting is as below -
# The default provider configuration provider "aws" { region = "us-east-1" }

Question115: Your configuration file has been locked accidentally. What of the following command would you use to unlock?

Question116: Terraform can run on Windows or Linux, but it requires a Server version of the Windows operating system.

Question117: Select the most accurate statement to describe the Terraform language from the following list.

Question118: How is terraform import run?

Question119: During a terraform apply, a resource is successfully created but eventually fails during provisioning. What happens to the resource?

Question120: Which of the following commands will launch the Interactive console for Terraform interpolations?

Question121: You run a local-exec provisioner in a null resource called null_resource.run_script and realize that you need to rerun the script.
Which of the following commands would you use first?

Question122: You would like to reuse the same Terraform configuration for your development and production environments with a different state file for each.
Which command would you use?

Question123: Which flag would you add to terraform plan to save the execution plan to a file?
Type your answer in the field provided. The text field is not case-sensitive and all variations of the correct answer are accepted.

Question124: What command should you run to display all workspaces for the current configuration?

Question125: In a Terraform Cloud workspace linked to a version control repository, speculative plan runs start automatically when you merge or commit changes to version control.

Question126: You have created an AWS EC2 instance of type t2.micro through your terraform configuration file ec2.tf . Now you want to change the instance type from t2.micro to t2.medium. Accordingly you have changed your configuration file and and ran terraform plan. After running terraform plan you check the output and saw one instance will be updated from t2.micro --> t2.medium. After this you went to grab a coffee without running terraform apply and meanwhile a member of your team changed the instance type of that EC2 instance to t2.medium from aws console. After coming to your desk you run terraform apply. What will happen?

Question127: If a module declares a variable with a default, that variable must also be defined within the module.

Question128: How can you trigger a run in a Terraform Cloud workspace that is connected to a Version Control System (VCS) repository?

Question129: Which of the following command can be used to view the specified version constraints for all providers used in the current configuration.

Question130: Command terraform refresh will update state file?

Question131: You have already set TF_LOG = DEBUG to enable debug log. Now you want to always write the log to the directory you're currently running terraform from. what should you do to achieve this.

Question132: When using a module block to reference a module stored on the public Terraform Module Registry such as:

How do you specify version 1.0.0?

Question133: Multiple configurations for the same provider can be used in a single configuration file.

Question134: When running the command terraform taint against a managed resource you want to force recreation upon, Terraform will immediately destroy and recreate the resource.